import xjhRequest from '../index';

import { IAccount, ILoginResult } from './type';
import { IDataType } from '@/service/types/type';

enum LoginAPI {
  AccountLogin = '/login',
  LoginUserInfo = '/users/',
  UserMenus = '/role/' // role/roleId/
}

export function accountLoginRequest(account: IAccount) {
  return xjhRequest.post<IDataType<ILoginResult>>({
    url: LoginAPI.AccountLogin,
    data: account
  });
}

export function requestUserInfoById(id: number) {
  return xjhRequest.get<any>({
    url: LoginAPI.LoginUserInfo + id
  });
}

// 获取表单
export function requestUserMenusByRoleId(id: number) {
  return xjhRequest.get<any>({
    url: LoginAPI.UserMenus + id + '/menu'
  });
}
